import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";

@Entity("private_charge_record", { schema: "charge" })
export class PrivateChargeRecord {
  @PrimaryGeneratedColumn({ type: "int", name: "id", unsigned: true })
  id: number;

  @Column("int", {
    name: "user_id",
    comment: "用户id",
    unsigned: true,
    default: () => "'0'",
  })
  userId: number;

  @Column("int", {
    name: "device_id",
    comment: "设备号",
    unsigned: true,
    default: () => "'0'",
  })
  deviceId: number;

  @Column("tinyint", {
    name: "port",
    comment: "端口号",
    unsigned: true,
    default: () => "'0'",
  })
  port: number;

  @Column("tinyint", {
    name: "fee_type",
    comment: "扣费模式,0:时间，1：电量，3：金额",
    default: () => "'0'",
  })
  feeType: number;

  @Column("float", {
    name: "precharge",
    comment: "预充",
    precision: 12,
    default: () => "'0'",
  })
  precharge: number;

  @Column("float", {
    name: "consume_kwh",
    comment: "实际消耗的电量",
    precision: 12,
    default: () => "'0'",
  })
  consumeKwh: number;

  @Column("tinyint", {
    name: "stop_reason",
    comment: "停止充电原因",
    unsigned: true,
    default: () => "'0'",
  })
  stopReason: number;

  @Column("json", {
    name: "charge_data",
    nullable: true,
    comment: "其它的信息",
  })
  chargeData: object | null;

  @Column("tinyint", {
    name: "status",
    comment: "0:等待开始充电,1:充电中,2:充电完成，3：充电失败",
    unsigned: true,
    default: () => "'0'",
  })
  status: number;

  @Column("tinyint", {
    name: "error_code",
    unsigned: true,
    default: () => "'0'",
  })
  errorCode: number;

  @Column("int", {
    name: "create_time",
    comment: "创建时间",
    unsigned: true,
    default: () => "'0'",
  })
  createTime: number;

  @Column("int", {
    name: "end_time",
    comment: "结束时间",
    unsigned: true,
    default: () => "'0'",
  })
  endTime: number;
}
